  var id= getvl("id");
 $("#tuijian").html("推荐商品(0/30)"); 

  var str="";
 
   str= getvl("chanshu");
   var strs=str.split(",");
   
 var userid=getvl("userid");
 $(function(){
 	
 	     	weihuofabu(str);
 });
 
 
function weihuofabu(str){
	alert(".000.."+str);
    	$("#fabuweihuo").html("");
		
	     var sun=0;
	       	$.each(strs, function(index, value) {
				sun++;
			});
			 $("#tuijian").html("推荐商品("+sun+"/30)"); 
			 
			 	if(sun<30){
			 		
			 			 $.ajax({
      url: urlcore + "/api/goods/selectgoodsAllag?str="+str,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					var sun=1;
					alert(JSON.stringify(data.data));
					$.each(data.data, function(y,n) {
						var fabuweihuo='<div class="clearfix add_goods">'+
'		<div class="public-xuanze fl" >'+
'			<img src="../images/delete.png" onclick="removeByValues('+n.id+')" width="20" height="20" />'+
'		</div>'+
'		<div class="clearfix tuwen">'+
'	    	<a href="javascript:void(0);">'+
'		        <div class="tuwen-img fl">'+
'		            <img src="'+n.coverUrl+'" width="75" height="75">'+
'		        </div>'+
'		        <div class="tuwen-wenzi">'+
'		            <h5 class="wuye_h01">'+n.goodsTitle+'</h5>'+
'		            <div class="wuye_div02">&yen;'+n.tradePrice+'-&yen;'+n.getPrice+'<span class="P-tuifei">修改价格</span></div>'+
'		        </div>'+
'	        </a>'+
'	    </div>'+
'	</div>';
                 $("#fabuweihuo").append(fabuweihuo);
					});
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}
			},
			error: function() {
				alert("error");
			}
		});	
		
			 		
			 	}else{
				alert("超出商品范围...");
				 $("#tuijian").html("推荐商品(0/30)"); 
					$("#fabuweihuo").html("");
			}
			
}

 //提交
   function tijiaos(){
   	if(id!=''){
   			var sts=strs.toString();
      	alert(sts);
        var fengmian=$("#fengmian").val();
        var biaoti=$("#biaoti").val();
        var zhekou=$("#zhekou").val();
		 $.ajax({
		url: urlcore + "/api/zbDirectSeeding/addPublic2",
		type: "post",
		contentType: "application/json;charset=utf-8",
		data: JSON.stringify({
	  sellerId:id,	
      imgUrl:fengmian,
      title:biaoti,
      packRate:zhekou,
      goodsIds:sts
		}),
		dataType: "json",
		success: function(data) {
			if(data.success == true) {
				alert("添加成功！");
		      window.location.href ="22.1.1huodong_zhibo_shenqing.html";
		     }
		},error: function() {
			alert("error");
		}
	});
		
   	}else{
   		alert("异常");
   	}
      
	
  
   }
   
   
   



//删除数组元素
function removeByValues(val) {
	alert("..."+val);
  removeByValue(strs,val);
    strs.toString();
 alert(strs.toString())
  weihuofabu(strs);
}

